package com.songcha.library_business.bean.book

import android.os.Parcel
import android.os.Parcelable
import java.io.Serializable

/***
 * distinguish local book bean,net book bean,database book bean
 */
data class BookBean(var id:String="",
                    var bookName:String="",
                    var author:String="",
                    var thumb:String="",
                    var textCount:Int=0,
                    var isFromSDCard:Boolean=false,
                    //local book path
                    var path:String="",
    var fontPath:String=""

    ):Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readInt(),
        parcel.readByte() != 0.toByte(),
        parcel.readString()?:"",
        parcel.readString()?:""
    ) {
    }


    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(bookName)
        parcel.writeString(author)
        parcel.writeString(thumb)
        parcel.writeInt(textCount)
        parcel.writeByte(if (isFromSDCard) 1 else 0)
        parcel.writeString(path)
        parcel.writeString(fontPath)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<BookBean> {
        override fun createFromParcel(parcel: Parcel): BookBean {
            return BookBean(parcel)
        }

        override fun newArray(size: Int): Array<BookBean?> {
            return arrayOfNulls(size)
        }
    }

}